<?php
//数据组-数据库实例
namespace Biz\model\bigData;

/**
 * 品牌周报--线上用
 * Class BrandWeeklyReport
 * @package Biz\model\bigData
 */
class BrandWeeklyReport extends \Doraemon\pockets\datebase\BaseDbModel
{
    const _CONFIG_FILE_ = 'db_bigdata_online';

    const _CONFIG_SELECT_ = 'bigdata_centre';

    const _DATABASE_ = 'hhz_bigdata_online';

    const _TABLE_NAME = 'brand_weekly_report';

    public static function getWeeklyDay()
    {
        $time = time();
        $today = date('Ymd');
        $week = date('w', $time);
        $week = ($week == 0) ? 7 : $week;
        $cycleStart = 7;
        $nowWeekDay = date("Ymd", ($cycleStart - $week) * 86400 + $time);
        $lastWeekDay = date('Ymd', strtotime('-7 days', strtotime($nowWeekDay)));
        $nextWeekDay = date('Ymd', strtotime('+7 days', strtotime($nowWeekDay)));
        $weeklyDay = $nowWeekDay;
        if ($today >= $lastWeekDay && $today < $nowWeekDay) {
            $weeklyDay = $lastWeekDay;
        } else if ($today >= $nowWeekDay && $today < $nextWeekDay) {
            $weeklyDay = $nowWeekDay;
        }
        return $weeklyDay;
    }
}